package com.chen.service.Impl;

import com.chen.mapper.StudentMapper;
import com.chen.pojo.PageResult;
import com.chen.pojo.Student;
import com.chen.service.StudentService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public PageResult<Student> page(String name, Integer degree, Integer clazzId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Student> rows=studentMapper.page(name,degree,clazzId);
        Page<Student> p=(Page<Student>) rows;
        return new PageResult<Student>(p.getTotal(),p.getResult());
    }

    @Override
    public void deleteByIds(List<Integer> ids) {
        studentMapper.deleteByIds(ids);
    }
    @Override
    public void add(Student student) {
        studentMapper.add(student);
    }

    @Override
    public Student getInfo(Integer id) {
        Student student = studentMapper.getInfo(id);
        return student;
    }

    @Override
    public void update(Student student) {
        studentMapper.update(student);
    }

    @Override
    public void updatescore(Integer id, Integer score) {
        studentMapper.updatescore(id,score);
    }

}
